package org.phoenixframework.common.security.entity;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @author doublelifeke
 * Email: hautxxxyzjk@163.com
 * DateTime: 2021/5/7 17:22
 * Description:
 */
@Setter
@Getter
public class PhoenixSecurityUser implements UserDetails {

    private Long id;

    private Long deptId;

    private String username;

    private String password;

    private List<GrantedAuthority> authorities;

    public PhoenixSecurityUser() {
    }

    public PhoenixSecurityUser(Long id, Long deptId, String username, String password, List<GrantedAuthority> authorities) {
        this.id = id;
        this.deptId = deptId;
        this.username = username;
        this.password = password;
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
